<template>
  <el-row class="lo"> 
    <el-row class="logon-box">
      <el-col :span="12" class="logon-box">
        <el-col :span="12">
          <img src="../../public/img/icons/logon.png" alt="">
        </el-col>
        <el-col :span="12">
          <el-col :span="4">

          </el-col>
          <!-- <el-col :span="12">
          <el-form status-icon label-width="100px" class="demo-ruleForm">
            <el-input type="password" autocomplete="off"></el-input>
            </el-form-item>
            <el-input type="password" autocomplete="off"></el-input>
            <el-button type="primary">提交</el-button>
            <el-button>重置</el-button>
          </el-form>
        </el-col> -->
          <el-col :span="16" class="center-container">
            <h2>后台管理系统</h2>
            <p>MANAGEMENT SYSTEM</p>
            <div class="username-input">
              <el-input placeholder="用户名"></el-input>
              <p>1</p>
            </div>
            <div class="password-input">
              <el-input placeholder="密码"></el-input>
              <p>2</p>
            </div>
            <div>
              <el-button @click="logOn" style="width: 100%;">提交</el-button>
            </div>
          </el-col>
          <el-col :span="4">

          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </el-row>
</template>
<style scoped lang="scss">
.logon-box {
  height: 700px;
  background-color: white;
}

.logon-box img {
  width: 100%;
  height: 700px;
}

.center-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 600px;
  width: 300px;
  margin-left: 50px;
}

.center-container {
  width: 300px;

  el-input {
    width: 100px;
  }
}

.center-container .username-input {
  text-align: left;
  margin-bottom: 10px;

  p {
    color: red;
  }
}

.center-container .password-input {
  text-align: left;

  // margin-bottom: 40px;
  p {
    color: red;
  }
}
</style>
<script>

import axios from 'axios'
export default {
  data() {
    return {
      form: {
        username: '',
        password: ''
      },
      baseURL: 'http://43.138.15.137:7000/api/private/v1'
    }
  },
  methods: {
    logOn() {
      axios.post(this.baseURL + '/login', this.form).then(res => {
        let { data: { data, meta } } = res
        if (meta.status === 200) {
          this.$message({
            message: '登录成功',
            type: 'success'
          })
          localStorage.setItem('token', data.token)
          this.$router.push({
            path: '/list'
          })
        } else {
          this.$message({
            message: meta.msg,

            type: 'error'
          })
          return
        }
      })
    }
  }
}
</script>
